package com.xuecheng.content.convert;

import com.xuecheng.api.content.model.dto.CourseBaseDTO;
import com.xuecheng.api.content.model.vo.CourseAuditVo;
import com.xuecheng.api.content.model.vo.CourseBaseVo;
import com.xuecheng.content.entity.CourseBase;
import com.xuecheng.content.entity.CourseMarket;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;
import java.util.List;

@Mapper//标记为mapstruct转换器
public interface CourseBaseConvert {

    //使用mapstruct的Api构建出接口的对象
    CourseBaseConvert INSTANCE = Mappers.getMapper(CourseBaseConvert.class);

    //单个对象转换方法
    @Mapping(source = "id",target = "courseBaseId")
    CourseBaseDTO entity2dto(CourseBase courseBase);

    //多个同类型对象转换方法,多个转换的时候依赖单个
    List<CourseBaseDTO> entitys2dtos(List<CourseBase> list);

    //Vo转为DTO
    CourseBaseDTO vo2dto(CourseBaseVo courseBaseVo);

    //DTO转为Po
    @Mapping(source = "courseBaseId",target = "id")
    CourseBase dto2po(CourseBaseDTO courseBaseDTO);

    //CourseMarker转为DTO
    CourseBaseDTO marker2dto(CourseMarket courseMarket);

    //CourseAuditVo转dto
    CourseBaseDTO audit2to(CourseAuditVo courseAuditVo);
}
